package com.fsc.rc.infra.help;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Date Helper Class
 * @author Colin
 *
 */
public class DateFormat {

	static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
	
	/**
	 * Get date format "yyyyMMdd".
	 * @param date
	 * @return
	 */
	public static String getFormatDate(Date date){
		return dateFormat.format(date);
	}
	
	/**
	 * Get Date Format "yyyyMMdd".
	 * @param calendar
	 * @return
	 */
	public static String getFormatDate(Calendar calendar){
		return dateFormat.format(calendar);
	}
	
	/**
	 * Get Date Format "yyyyMMdd".
	 * @param sdate
	 * @return
	 */
	public static Date getFormatDate(String sdate){
		Date date = null;
		try {
			date = dateFormat.parse(sdate);
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return date;
	}
}
